<meta charset="utf-8">
<div style="width:100%" id='reservaView'>
<input type="hidden" id="base_url" value="<?=base_url()?>">
    <?php
    foreach ($reservas as $row){
        $this->table->set_heading('ID','Usuário','Descrição','Status',
                    'Inicio','Fim','Agendamento','Aprovação','Contrato','Aprova','Exclui'
        );
        $dtreserva = $row->dtreserva != NULL ? $dtreserva = date('d/m/Y',(strtotime($row->dtreserva))) : "Aguardando Aprovação";
        if($row->dtreserva != NULL){
            $acao = "reserva/libera/$row->idreserva";
        }
        else{
            $acao = "reserva/aprova/$row->idreserva";
        }
        $aprovacao = $row->dtreserva != NULL ? $aprovacao = "<img src=".base_url()."img/icons/dislike_16x16.png>"
                : "<img src=".base_url()."img/icons/like_16x16.png>";                
        $this->table->add_row($row->idreserva, $row->nome, 
            $row->descricao_reserva, $row->descricao_status, date('d/m/Y',(strtotime($row->dtinicial))), date('d/m/Y',(strtotime($row->dtfinal))), 
            date('d/m/Y',(strtotime($row->dtagendamento))), $dtreserva,
            anchor("contrato/ensaio/$row->token", "<img src=".base_url()."img/icons/printer_16x16.png>", array('id'=>'grContrato')),                      
            anchor($acao,$aprovacao),
            anchor("reserva/exclui/$row->idreserva","<img src=".base_url()."img/icons/delete_16x16.png>", array('id'=>'exclui', 'value'=>$row->idreserva))
        ); 
    }
    $tmpl = array ( 'table_open'  => '<table class="display" id="treserva">' );
    $this->table->set_template($tmpl);
    echo $this->table->generate();
    ?>
</div>